<template>
  <header>
    <div class="icon-location-box">
      <i class="iconfont icon-spiritling-dingwei icon1"></i>
    </div>
    <div class="location-text">
      <el-dropdown>
        <span class="el-dropdown-link">
          {{position.defaultPosition}}
          <el-icon class="el-icon--right">
            <arrow-down />
          </el-icon>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item
                v-for="(item,index) in position.locationList"
                :key="index"
                @click="changeCity(index)"
            >{{item}}
            </el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </header>

  <div class="search">
    <!-- 当滚动条超过上面的定位块时，search-fixed-top块变成固定在顶部。 -->
    <div class="search-fixed-top" id="fixedBox">
      <!-- 搜索框部分中间的白框 -->
      <div class="search-box" @click="toSearch">
        <el-icon class="el-icon--right">
          <Search/>
        </el-icon>搜索饿了么商家、商品名称
      </div>
    </div>
  </div>
<!--  {{title}}-->
</template>

<script setup>
import { ArrowDown, Search } from '@element-plus/icons-vue'
import {reactive} from "vue";

// defineProps({
//   title: Number
// })
let position = reactive({
  defaultPosition: '北京',
  locationList: ['北京', '上海', '广州', '成都']
})

let changeCity = (index) => {
  position.defaultPosition = position.locationList[index]
}


</script>
<style scoped>
header{
  width: 100%;
  height: 12vw;
  background-color: #0097FF;
  display: flex;
  align-items: center;
}
header .icon-location-box{
  width: 3.5vw;
  height: 3.5vw;
  margin: 0 3vw 0 3vw;
  text-align: center;
  display: flex;
  align-items: center;
}
header .icon-location-box i {
  color: white;
  font-size: 20px;
}
header .location-text span {
  font-size: 4.5vw;
  font-weight: 700;
  color: #fff;
}
/****************** search ******************/
.search{
  width: 100%;
  height: 13vw;
}
.search .search-fixed-top{
  width: 100%;
  height: 13vw;
  background-color: #0097FF;
  display: flex;
  justify-content: center;
  align-items: center; }
.search .search-fixed-top .search-box{
  width: 90%;
  height: 9vw;
  background-color: #fff;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;

  font-size: 3.5vw;
  color: #AEAEAE;
  font-family: "宋体";
  /*此样式是让文本选中状态无效*/
  user-select: none; }
.search .search-fixed-top .search-box .fa-search{
  margin-right: 1vw; }
</style>